import service from '@/utils/request'

export const getResourceList = (data) => {
	return service({
		url: '/resource/getResourceList',
		method: 'post',
		data
	})
}

// @Tags 资源
// @Summary 创建基础资源
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body api.CreateApiParams true "创建api"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /resource/saveResource [post]
export const saveResource = (data) => {
	return service({
		url: '/resource/saveResource',
		method: 'post',
		data
	})
}

// @Tags menu
// @Summary 根据id获取菜单
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body api.GetById true "根据id获取菜单"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /menu/getApiById [post]
export const getApiById = (data) => {
	return service({
		url: '/api/getApiById',
		method: 'post',
		data
	})
}

// @Tags Api
// @Summary 更新api
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body api.saveResourceParams true "更新api"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /api/updateApi [post]
export const updateApi = (data) => {
	return service({
		url: '/api/updateApi',
		method: 'post',
		data
	})
}

// @Tags Api
// @Summary 更新api
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body api.CreateApiParams true "更新api"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /api/setAuthApi [post]
export const setAuthApi = (data) => {
	return service({
		url: '/api/setAuthApi',
		method: 'post',
		data
	})
}

// @Tags Api
// @Summary 获取所有的Api 不分页
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /api/getAllApis [post]
export const getAllApis = (data) => {
	return service({
		url: '/api/getAllApis',
		method: 'post',
		data
	})
}

// @Tags Api
// @Summary 删除指定api
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body dbModel.Api true "删除api"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /api/deleteResource [post]
export const deleteResource = (data) => {
	return service({
		url: '/resource/deleteResource',
		method: 'post',
		data
	})
}
